/*
 * Copyright © 2017 eqxiu.com 北京中网易企秀科技有限公司  All rights reserved.
 */
package cn.hermit.data.xml.model;

import cn.hermit.util.StringUtils;

/**
 * Java model of XML Header.
 * 
 * @author Jack Gao (Chinese name : GAO JIANGUO, Email : linux.gjg@gmail.com)
 * @date 19 Jun, 2014
 */
public final class XmlHeader extends XmlNode {

	/**
	 * 
	 */
	private static final long serialVersionUID = -7339562778198207409L;

	String version;

	String encoding;

	String standalone;

	XmlHeader() {
	}

	/**
	 * @return the version
	 */
	public String getVersion() {
		return version;
	}

	/**
	 * @return the encoding
	 */
	public String getEncoding() {
		return encoding;
	}

	/**
	 * @return the standalone
	 */
	public String getStandalone() {
		return standalone;
	}

	/**
     * Serialize XML Header to XML string.
     */
	public String toString() {
		StringBuilder b = new StringBuilder();
		b.append("<?xml ");
		if (this.version != null) {
			b.append("version=\"").append(this.version).append("\" ");
		}
		if (this.encoding != null) {
			b.append("encoding=\"").append(this.encoding).append("\" ");
		}
		if (this.standalone != null) {
			b.append("standalone=\"").append(this.standalone).append("\" ");
		}
		b.append("?>");
		return b.toString();
	}

	@Override
	public String toFormatString(int depth, String newLineFeed,
			boolean newLineForTexts) {
		return StringUtils.tabs(depth) + toString();
	}

	@Override
	public boolean isDocument() {
		return false;
	}

	@Override
	public boolean isElement() {
		return false;
	}

	@Override
	public boolean isAttribute() {
		return false;
	}

	@Override
	public boolean isText() {
		return false;
	}

	@Override
	public boolean isPureText() {
		return false;
	}

	@Override
	public boolean isCdata() {
		return false;
	}

	@Override
	public boolean isComment() {
		return false;
	}

	@Override
	public boolean isHeader() {
		return true;
	}

	@Override
	public boolean isNameNode() {
		return false;
	}

}